[MS Access 2003 SQL] Switch is causing #error, why and how can I fix it...

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-05-11T22:03:39Z Indexed on 2010/05/11 23:24 UTC
Read the original article Hit count: 156

Filed under:
|

I have 3 fields in my table: start, end (dates) and length (number, might be blank).
My Aim is to calculate an end date using start and length where end doesn't exist...

I have:

SELECT Switch((g.length<>0) And IsDate(g.end),DateAdd("m",g.length,g.start)) AS field FROM table g

If there is no start, end or length, Access displays blank - this is fine. If there is no end, but start and length are ok, the calculated date is shown - again fine. BUT If there is no end, or length, but a start exists, access displays #Error

I don't understand why, and can't fix it, please help!

© Stack Overflow or respective owner

Related posts about ms-access

Related posts about sql